﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bettzueche.RLGlue.TaskSpec {
    /// <summary>
    /// 
    /// </summary>
    internal class TaskSpecV30 : ITaskSpec{

        private const String _OUR_VERSION = "RL-Glue-3.0";

        /// <summary>
        /// Initializes a new instance of the <see cref="TaskSpecV30"/> class.<para>
        /// Observations, Actions and Extra are empty, Reward range is infinity.</para>
        /// </summary>
        internal TaskSpecV30() {
            Observations = new RLTypesSpec();
            Actions = new RLTypesSpec();
            Reward = new DoubleRange { Cardinality = 1, Min = Double.MinValue, Max = Double.MaxValue };
            Extra = "";
        }

        #region ITaskSpec Members


        /// <summary>
        /// Returns the string representation of the Task Spec object.
        /// </summary>
        public string Version {
            get { return _OUR_VERSION; }
        }

        /// <summary>
        /// Gets or sets the propblemtype.
        /// episodic | continuous | something else
        /// </summary>
        public string Propblemtype { get; internal protected set; }

        /// <summary>
        /// Gets the discountfactor gamma in [0,1]
        /// </summary>
        public double Discountfactor {
            get;
            internal protected set;
        }

        /// <summary>
        /// Gets the observation ranges.
        /// </summary>
        public RLTypesSpec Observations {
            get;
            internal protected set;
        }

        /// <summary>
        /// Gets the action ranges.
        /// </summary>
        public RLTypesSpec Actions {
            get;
            internal protected set;
        }

        /// <summary>
        /// Gets the reward range.
        /// </summary>
        public DoubleRange Reward {
            get;
            internal protected set;
        }

        string _extra;
        /// <summary>
        /// Gets or sets the extra.
        /// </summary>
        /// <value>
        /// The extra.
        /// </value>
        public string Extra {
            get { return _extra; }
            set {
                _extra = value == null ? "" : value;
            }
        }

        /// <summary>
        /// Gets the task spec string.
        /// </summary>
        /// <returns></returns>
        public string ToTaskSpecString() {
            ITaskSpecSerializer serializer = new TaskSpecV30Serializer();
            return serializer.Serialize(this);
        }

        #endregion
    }
}
